package org.algorithm;

import java.util.List;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;

public class SecretGen {

    private static final char[] chars = new char[]{'0','1','2','3','4','5','6','7','8','9','a','b','c','d'
            ,'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

    private static final Integer seed = 0;

    public static String getLowIndex(){
        char[] tempchars = new char[24];
        for (int i=0 ;i<24;i++) {
            tempchars[i] = chars[ThreadLocalRandom.current().nextInt(36)];
        }
        return String.valueOf(tempchars);
    }

    public static void main(String[] args) throws InterruptedException {

        Long mill = System.currentTimeMillis();
        CountDownLatch latch = new CountDownLatch(10);
        ExecutorService service = Executors.newFixedThreadPool(10);
        for (int i=0 ;i<10;i++) {
            service.submit(new Runnable() {
                @Override
                public void run() {
                    for (int i=0 ;i<100000;i++) {
                        System.out.println(getLowIndex());
//                        getLowIndex();
//                        UUID.randomUUID();
                    }
                    latch.countDown();
                }
            });
        }
        latch.await();
//        for (int i=0 ;i<1000000;i++) {
//            getLowIndex();
//        }
        System.out.println(System.currentTimeMillis() - mill);
    }
}
